<template>
	<div id="dz-tofs-add">
	<d2-container better-scroll>
		<template slot="header">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item>资源宝库</el-breadcrumb-item>
				<el-breadcrumb-item>添加资源</el-breadcrumb-item>
				<el-link><i class="el-icon-refresh"></i></el-link>
			</el-breadcrumb>
		</template>
		 <el-alert
		    title="如果目录为顶级目录则不用选择上级目录"
		    type="success">
		  </el-alert>
		<el-form ref="form" :model="form" label-width="80px">
			<el-form-item label="资源名称">
				<el-input v-model="form.name" placeholder="请输入资源名称"></el-input>
			</el-form-item>
			<el-form-item label="资源类型">
				<el-radio-group v-model="form.type">
					<el-radio :label="0">目录</el-radio>
					<el-radio :label="1">菜单</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item label="上级目录">
				<div class="block">
				  <el-cascader
				    placeholder="请选择上级目录"
				    :options="options"
				    filterable></el-cascader>
				</div>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="onSubmit">立即创建</el-button>
				<el-button>取消</el-button>
			</el-form-item>
		</el-form>
	</d2-container>
	</div>
</template>

<script>
	import * as add from '@/api/tofs/add.js'
	export default {
		data() {
			return {
				form: {
					name: '',
					type: 0,
				}
			}
		},
		methods: {
			onSubmit() {
				add.add(this.form).then(res=>{
					console.log(res)
				});
			}
		}
	}
</script>
<style>
	#dz-tofs-add .el-alert,.el-alert--success,.is-light{
		margin-bottom: 20px;
	}
</style>